package com.wchc.exception;

import com.wchc.entities.base.ResultVo;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.util.Objects;

/**
 * 全局异常拦截类
 */
@RestControllerAdvice
public class GlobalExceptionHandler {
    // 全局异常拦截 
    @ExceptionHandler
    public ResultVo handlerException(Exception e) {
        if(Objects.nonNull(e)){
            try {
                e.printStackTrace();
            } catch (Exception ex) {
                throw new RuntimeException(ex);
            }
        }
        return ResultVo.error().message(e.getMessage());
    }
}